package com.lego.service.impl;

import java.util.List;

import com.lego.bean.Goods;
import com.lego.bean.Page;
import com.lego.dao.GoodsDao;
import com.lego.dao.impl.GoodsDaoImpl;
import com.lego.service.GoodsService;

public class GoodsServiceImpl implements GoodsService {
	
	GoodsDao gd = new GoodsDaoImpl();
	
	@Override
	public Page<Goods> selcetGoods(int pageNum, int pageSize,String keyWord,String goodsType) {
		if(goodsType!=null&&goodsType.equals("全部")) {
			goodsType = "";
		}
		List data = gd.selectGoods(pageNum,pageSize,keyWord,goodsType);
		int totalRows = gd.selectAllRows(goodsType,keyWord);
		return new Page(data,pageNum,pageSize,totalRows,keyWord,goodsType);
	}

	@Override
	public Goods selectByGoodsId(int goodsId) {
		return gd.selectByGoodsId(goodsId);
	}

	@Override
	public int changeQuantity(int negativeNumber,int goodsId) {
		return gd.changeQuantity(negativeNumber,goodsId);
	}

	@Override
	public int updateGoods(Goods goods) {
		// TODO Auto-generated method stub
		System.out.println("啥呀");
		return gd.updateGoods(goods);
	}

	@Override
	public int updateGoodsQuantity(int goodsId) {
		// TODO Auto-generated method stub
		return gd.updateGoodsQuantity(goodsId);
	}

	@Override
	public int addGoods(Goods goods) {
		// TODO Auto-generated method stub
		return gd.addGoods( goods);
	}

}
